\(\int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx\) [45]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [F(-2)]
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 34, antiderivative size = 103 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=-\frac {(A+3 i B) x}{4 a^2}+\frac {B \log (\cos (c+d x))}{a^2 d}+\frac {i A-3 B}{4 a^2 d (1+i \tan (c+d x))}+\frac {(i A-B) \tan ^2(c+d x)}{4 d (a+i a \tan (c+d x))^2} \]

[Out]

-1/4*(A+3*I*B)*x/a^2+B*ln(cos(d*x+c))/a^2/d+1/4*(I*A-3*B)/a^2/d/(1+I*tan(d*x+c))+1/4*(I*A-B)*tan(d*x+c)^2/d/(a
+I*a*tan(d*x+c))^2

Rubi [A] (verified)

Time = 0.25 (sec) , antiderivative size = 103, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.176, Rules used = {3676, 3670, 3556, 12, 3607, 8} \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {-3 B+i A}{4 a^2 d (1+i \tan (c+d x))}-\frac {x (A+3 i B)}{4 a^2}+\frac {B \log (\cos (c+d x))}{a^2 d}+\frac {(-B+i A) \tan ^2(c+d x)}{4 d (a+i a \tan (c+d x))^2} \]

[In]

Int[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^2,x]

[Out]

-1/4*((A + (3*I)*B)*x)/a^2 + (B*Log[Cos[c + d*x]])/(a^2*d) + (I*A - 3*B)/(4*a^2*d*(1 + I*Tan[c + d*x])) + ((I*
A - B)*Tan[c + d*x]^2)/(4*d*(a + I*a*Tan[c + d*x])^2)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3607

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(-(
b*c - a*d))*((a + b*Tan[e + f*x])^m/(2*a*f*m)), x] + Dist[(b*c + a*d)/(2*a*b), Int[(a + b*Tan[e + f*x])^(m + 1
), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0]

Rule 3670

Int[(((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]))/((a_.) + (b_.)*tan[(e_.)
 + (f_.)*(x_)]), x_Symbol] :> Dist[B*(d/b), Int[Tan[e + f*x], x], x] + Dist[1/b, Int[Simp[A*b*c + (A*b*d + B*(
b*c - a*d))*Tan[e + f*x], x]/(a + b*Tan[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a
*d, 0]

Rule 3676

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[(-(A*b - a*B))*(a + b*Tan[e + f*x])^m*((c + d*Tan[e + f*x])^n/(2*a*f
*m)), x] + Dist[1/(2*a^2*m), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^(n - 1)*Simp[A*(a*c*m + b*d
*n) - B*(b*c*m + a*d*n) - d*(b*B*(m - n) - a*A*(m + n))*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, A
, B}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] && LtQ[m, 0] && GtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(i A-B) \tan ^2(c+d x)}{4 d (a+i a \tan (c+d x))^2}-\frac {\int \frac {\tan (c+d x) (2 a (i A-B)+4 i a B \tan (c+d x))}{a+i a \tan (c+d x)} \, dx}{4 a^2} \\ & = \frac {(i A-B) \tan ^2(c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac {i \int -\frac {2 a^2 (A+3 i B) \tan (c+d x)}{a+i a \tan (c+d x)} \, dx}{4 a^3}-\frac {B \int \tan (c+d x) \, dx}{a^2} \\ & = \frac {B \log (\cos (c+d x))}{a^2 d}+\frac {(i A-B) \tan ^2(c+d x)}{4 d (a+i a \tan (c+d x))^2}-\frac {(i A-3 B) \int \frac {\tan (c+d x)}{a+i a \tan (c+d x)} \, dx}{2 a} \\ & = \frac {B \log (\cos (c+d x))}{a^2 d}+\frac {(i A-B) \tan ^2(c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac {i A-3 B}{4 d \left (a^2+i a^2 \tan (c+d x)\right )}-\frac {(A+3 i B) \int 1 \, dx}{4 a^2} \\ & = -\frac {(A+3 i B) x}{4 a^2}+\frac {B \log (\cos (c+d x))}{a^2 d}+\frac {(i A-B) \tan ^2(c+d x)}{4 d (a+i a \tan (c+d x))^2}+\frac {i A-3 B}{4 d \left (a^2+i a^2 \tan (c+d x)\right )} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.85 (sec) , antiderivative size = 158, normalized size of antiderivative = 1.53 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {\sec ^2(c+d x) (-2 i A+4 B+\cos (2 (c+d x)) (2 i A-4 B+(-i A+7 B) \log (i-\tan (c+d x))+(i A+B) \log (i+\tan (c+d x)))+(-A-3 i B+(A+7 i B) \log (i-\tan (c+d x))-(A-i B) \log (i+\tan (c+d x))) \sin (2 (c+d x)))}{8 a^2 d (-i+\tan (c+d x))^2} \]

[In]

Integrate[(Tan[c + d*x]^2*(A + B*Tan[c + d*x]))/(a + I*a*Tan[c + d*x])^2,x]

[Out]

(Sec[c + d*x]^2*((-2*I)*A + 4*B + Cos[2*(c + d*x)]*((2*I)*A - 4*B + ((-I)*A + 7*B)*Log[I - Tan[c + d*x]] + (I*
A + B)*Log[I + Tan[c + d*x]]) + (-A - (3*I)*B + (A + (7*I)*B)*Log[I - Tan[c + d*x]] - (A - I*B)*Log[I + Tan[c
+ d*x]])*Sin[2*(c + d*x)]))/(8*a^2*d*(-I + Tan[c + d*x])^2)

Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.18

method result size
risch \(-\frac {7 i x B}{4 a^{2}}-\frac {x A}{4 a^{2}}-\frac {{\mathrm e}^{-2 i \left (d x +c \right )} B}{2 a^{2} d}+\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} A}{4 a^{2} d}+\frac {{\mathrm e}^{-4 i \left (d x +c \right )} B}{16 a^{2} d}-\frac {i {\mathrm e}^{-4 i \left (d x +c \right )} A}{16 a^{2} d}-\frac {2 i B c}{a^{2} d}+\frac {B \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{a^{2} d}\) \(122\)
derivativedivides \(\frac {i A}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )^{2}}-\frac {B}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )^{2}}-\frac {A \arctan \left (\tan \left (d x +c \right )\right )}{4 d \,a^{2}}-\frac {B \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \,a^{2}}-\frac {3 i B \arctan \left (\tan \left (d x +c \right )\right )}{4 d \,a^{2}}+\frac {5 i B}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )}+\frac {3 A}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )}\) \(137\)
default \(\frac {i A}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )^{2}}-\frac {B}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )^{2}}-\frac {A \arctan \left (\tan \left (d x +c \right )\right )}{4 d \,a^{2}}-\frac {B \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \,a^{2}}-\frac {3 i B \arctan \left (\tan \left (d x +c \right )\right )}{4 d \,a^{2}}+\frac {5 i B}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )}+\frac {3 A}{4 d \,a^{2} \left (\tan \left (d x +c \right )-i\right )}\) \(137\)

[In]

int(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

-7/4*I*x/a^2*B-1/4*x/a^2*A-1/2/a^2/d*exp(-2*I*(d*x+c))*B+1/4*I/a^2/d*exp(-2*I*(d*x+c))*A+1/16/a^2/d*exp(-4*I*(
d*x+c))*B-1/16*I/a^2/d*exp(-4*I*(d*x+c))*A-2*I*B/a^2/d*c+B/a^2/d*ln(exp(2*I*(d*x+c))+1)

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 84, normalized size of antiderivative = 0.82 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=-\frac {{\left (4 \, {\left (A + 7 i \, B\right )} d x e^{\left (4 i \, d x + 4 i \, c\right )} - 16 \, B e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 4 \, {\left (-i \, A + 2 \, B\right )} e^{\left (2 i \, d x + 2 i \, c\right )} + i \, A - B\right )} e^{\left (-4 i \, d x - 4 i \, c\right )}}{16 \, a^{2} d} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/16*(4*(A + 7*I*B)*d*x*e^(4*I*d*x + 4*I*c) - 16*B*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) + 4*(-I*A
 + 2*B)*e^(2*I*d*x + 2*I*c) + I*A - B)*e^(-4*I*d*x - 4*I*c)/(a^2*d)

Sympy [A] (verification not implemented)

Time = 0.31 (sec) , antiderivative size = 223, normalized size of antiderivative = 2.17 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {B \log {\left (e^{2 i d x} + e^{- 2 i c} \right )}}{a^{2} d} + \begin {cases} \frac {\left (\left (- 4 i A a^{2} d e^{2 i c} + 4 B a^{2} d e^{2 i c}\right ) e^{- 4 i d x} + \left (16 i A a^{2} d e^{4 i c} - 32 B a^{2} d e^{4 i c}\right ) e^{- 2 i d x}\right ) e^{- 6 i c}}{64 a^{4} d^{2}} & \text {for}\: a^{4} d^{2} e^{6 i c} \neq 0 \\x \left (- \frac {- A - 7 i B}{4 a^{2}} + \frac {\left (- A e^{4 i c} + 2 A e^{2 i c} - A - 7 i B e^{4 i c} + 4 i B e^{2 i c} - i B\right ) e^{- 4 i c}}{4 a^{2}}\right ) & \text {otherwise} \end {cases} + \frac {x \left (- A - 7 i B\right )}{4 a^{2}} \]

[In]

integrate(tan(d*x+c)**2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))**2,x)

[Out]

B*log(exp(2*I*d*x) + exp(-2*I*c))/(a**2*d) + Piecewise((((-4*I*A*a**2*d*exp(2*I*c) + 4*B*a**2*d*exp(2*I*c))*ex
p(-4*I*d*x) + (16*I*A*a**2*d*exp(4*I*c) - 32*B*a**2*d*exp(4*I*c))*exp(-2*I*d*x))*exp(-6*I*c)/(64*a**4*d**2), N
e(a**4*d**2*exp(6*I*c), 0)), (x*(-(-A - 7*I*B)/(4*a**2) + (-A*exp(4*I*c) + 2*A*exp(2*I*c) - A - 7*I*B*exp(4*I*
c) + 4*I*B*exp(2*I*c) - I*B)*exp(-4*I*c)/(4*a**2)), True)) + x*(-A - 7*I*B)/(4*a**2)

Maxima [F(-2)]

Exception generated. \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [A] (verification not implemented)

none

Time = 0.55 (sec) , antiderivative size = 107, normalized size of antiderivative = 1.04 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=-\frac {\frac {2 \, {\left (i \, A + B\right )} \log \left (\tan \left (d x + c\right ) + i\right )}{a^{2}} + \frac {2 \, {\left (-i \, A + 7 \, B\right )} \log \left (\tan \left (d x + c\right ) - i\right )}{a^{2}} + \frac {3 i \, A \tan \left (d x + c\right )^{2} - 21 \, B \tan \left (d x + c\right )^{2} - 6 \, A \tan \left (d x + c\right ) + 22 i \, B \tan \left (d x + c\right ) + 5 i \, A + 5 \, B}{a^{2} {\left (\tan \left (d x + c\right ) - i\right )}^{2}}}{16 \, d} \]

[In]

integrate(tan(d*x+c)^2*(A+B*tan(d*x+c))/(a+I*a*tan(d*x+c))^2,x, algorithm="giac")

[Out]

-1/16*(2*(I*A + B)*log(tan(d*x + c) + I)/a^2 + 2*(-I*A + 7*B)*log(tan(d*x + c) - I)/a^2 + (3*I*A*tan(d*x + c)^
2 - 21*B*tan(d*x + c)^2 - 6*A*tan(d*x + c) + 22*I*B*tan(d*x + c) + 5*I*A + 5*B)/(a^2*(tan(d*x + c) - I)^2))/d

Mupad [B] (verification not implemented)

Time = 7.15 (sec) , antiderivative size = 114, normalized size of antiderivative = 1.11 \[ \int \frac {\tan ^2(c+d x) (A+B \tan (c+d x))}{(a+i a \tan (c+d x))^2} \, dx=\frac {\frac {A}{2\,a^2}+\frac {B\,1{}\mathrm {i}}{a^2}+\mathrm {tan}\left (c+d\,x\right )\,\left (-\frac {5\,B}{4\,a^2}+\frac {A\,3{}\mathrm {i}}{4\,a^2}\right )}{d\,\left ({\mathrm {tan}\left (c+d\,x\right )}^2\,1{}\mathrm {i}+2\,\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (B+A\,1{}\mathrm {i}\right )}{8\,a^2\,d}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (-7\,B+A\,1{}\mathrm {i}\right )}{8\,a^2\,d} \]

[In]

int((tan(c + d*x)^2*(A + B*tan(c + d*x)))/(a + a*tan(c + d*x)*1i)^2,x)

[Out]

(A/(2*a^2) + (B*1i)/a^2 + tan(c + d*x)*((A*3i)/(4*a^2) - (5*B)/(4*a^2)))/(d*(2*tan(c + d*x) + tan(c + d*x)^2*1
i - 1i)) - (log(tan(c + d*x) + 1i)*(A*1i + B))/(8*a^2*d) + (log(tan(c + d*x) - 1i)*(A*1i - 7*B))/(8*a^2*d)